package org.totoro.concurrent;

import org.totoro.structure.list.List;
import org.totoro.structure.list.impl.ArrayList;

/**
 * @author daocr
 * @date 2021/5/25
 */
public class ThreadLocalTest {
    public static void main(String[] args) throws InterruptedException {

        ThreadLocal<Object> objectThreadLocal = new ThreadLocal<>();

        objectThreadLocal.set(new Object() {
            @Override
            protected void finalize() throws Throwable {
                System.out.println("回收成功");
            }
        });

        System.out.println(objectThreadLocal.get());

        Thread.sleep(1000);
//

        objectThreadLocal.remove();


        List<byte[]> list = new ArrayList<>();
        for (int i = 0; i < 1000; i++) {

            list.add(new byte[1024 * 1024 * 1]);

            System.out.println("申请1mb");
            System.gc();
            Thread.sleep(1000);
        }


    }
}
